
//
//  XSJZZJJFeedBackViewController.m
//  JJHome
//
//  Created by Meng Chen on 16/8/17.
//  Copyright © 2016年 LeeRay. All rights reserved.
//

#import "XSJZZJJFeedBackViewController.h"
#import "XSJZZJKPlaceholderTextView.h"
#import "XSJZZUIView+XBExtension.h"

@interface XSJZZJJFeedBackViewController ()
@property (nonatomic ,strong)XSJZZJKPlaceholderTextView *textView;
@end

@implementation XSJZZJJFeedBackViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationItem.title = @"反馈";
    self.view.backgroundColor = [UIColor whiteColor];
    
    //创建
    self.textView = [[XSJZZJKPlaceholderTextView alloc] initWithFrame:CGRectMake(10, 10, [UIScreen mainScreen].bounds.size.width - 20, 200)];
    
    self.textView.font = [UIFont systemFontOfSize:18];
    self.textView.backgroundColor = [UIColor lightGrayColor];
 
    self.textView.limitTextLength = 300;
    
    [self.view addSubview:self.textView];
    
    self.textView.limitTextLengthBlock = ^{
        
        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"提示" message:[NSString stringWithFormat:@"字符个数超出限制"] delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil];
        
        [alert show];
    };
    
    
    UIButton *loginBtn = [UIButton buttonWithType:UIButtonTypeSystem];
    loginBtn.width = 180;
    loginBtn.height = 30;
    loginBtn.centerX = self.view.width * 0.5;
    loginBtn.y = CGRectGetMaxY(_textView.frame) + 30;
    [loginBtn setTitle:@"提交反馈" forState:UIControlStateNormal];
    [loginBtn setBackgroundColor:[UIColor orangeColor]];
    [loginBtn addTarget:self action:@selector(done) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:loginBtn];

}
#warning mark 点击提交反馈的时候判断文本的长度
-(void)done{
    if (self.textView.text.length == 0) {
         [SVProgressHUD showInfoWithStatus:@"您还没有输入任何意见哦~"];
        return;
    }
    [SVProgressHUD showInfoWithStatus:@"我们已经收到您的反馈，感谢您的宝贵意见"];
   
    [self.navigationController popViewControllerAnimated:YES];
}

-(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
    [self.textView resignFirstResponder];
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
